package problem260;

//260.只出现一次的数字3
//https://leetcode.cn/problems/single-number-iii/

class Solution {
    public int[] singleNumber(int[] nums) {
        int xor = 0;
        for(int x : nums) 
            xor ^= x;
        int mask = xor & (-xor);
        int[] ret = new int[2];
        for(int x : nums) {
            if((x & mask) == 0) ret[0] ^= x;
            else ret[1] ^= x;
        }
        return ret;
    }
}
